/******************************************************************************************
 * Import
 ******************************************************************************************/

// module
import React, {Component} from 'react';
import {View, TouchableHighlight} from 'react-native';
import { Button, Modal, Icon} from 'antd-mobile-rn';

// project

import {
    CAround, CBetween, CCenter, CColumn, CHand, CItemX, CItemY, CLine, CRow, CWrap, 
    CIcon, CImage, CSvg, CText,
    CContent, CFloat, CFooter, CHeader, CPage, CSide, 
    CEmpty, CError, CFail, CSkeleton, 
    CLabel, CButton
} from '../../../../library/comp';



/******************************************************************************************
 * Export Class
 ******************************************************************************************/

export default class MyHouse extends Component {

    /*------------------------------------------------------------------------------------
	 * 初始化
	 *-----------------------------------------------------------------------------------*/
	constructor(props) {
        super(props);
        // this.Nav = this.props.navigation;

        /**
         * state
         */
		this.state = {
			apply:[
                {
                    id:1,
                    subdistrict_name:"珑城花园",
                    unit_name:"一号楼一单元",
                    enum_apply_status:"户主",
                    enum_checked:"审核中",

                },
                {
                    id:2,
                    subdistrict_name:"珑城花园",
                    unit_name:"一号楼二单元",
                    enum_apply_status:"户主",
                    enum_checked:"审核中",

                },
            ],
			house:[
                {
                    id:3,
                    subdistrict_name:"珑城花园",
                    unit_name:"二号楼一单元",
                    enum_status:"户主",
                },
                {
                    id:4,
                    subdistrict_name:"珑城花园",
                    unit_name:"二号楼二单元",
                    enum_status:"家属",
                },

            ],
			// default_houseid:null,
			default_houseid:3,
		};
    }
    
    componentDidMount(){
        // SplashScreen.hide();
        // HttpTemp.get({
        //     url:"/CPage/myhouse/list.php",
        //     success:(res) => {
        //         let data = res.data;
        //         console.log(res.data)
        //         this.setState({
		// 			apply:data.apply,
		// 			house:data.house,
		// 			default_houseid:data.default_houseid,
        //         })
        //     }
        // })


        



    }

    /*------------------------------------------------------------------------------------
	 * 自定义方法
	 *-----------------------------------------------------------------------------------*/
    /**
     * 点击撤销弹出弹窗
     */
    showConfirm = ()=>{
        Modal.alert('','撤销房屋申请，您或其他人与该房屋的一切认证关系和权限同时撤销，确定撤销?', [
            { CText: '确定', onPress: () => console.log('确定') },
            { CText: '取消', onPress: () => console.log('取消'), style: 'cancel' },
          ]);
    }

	/*------------------------------------------------------------------------------------
	 * 渲染
	 *-----------------------------------------------------------------------------------*/
	render() {
		return (
			<CPage>

                {/* 内容部分 */}
				<CContent mt='96' bg='#efeff4' pt='20' >

                    {/* 房屋列表 审核中 */}
                    {this.state.apply.map((item,index)=>{
                        return(
                            <View style={{
                                backgroundColor:'#fff', 
                                marginBottom: 10,
                                marginLeft: 10,
                                marginRight: 10,
                                borderRadius: 4
                            }}>
                                <CRow mx='20' bb='1 #f3f3f3' px='20' h='80' y='center'>
                                    <CBetween>
                                        <CHand y='center'>
                                            <CText size="28">{item.subdistrict_name}</CText>
                                        </CHand>
                                        <CHand y='center'>
                                            <CText size="28" bg='#3e86ea' color='#fff' size='24' px='20' py='8' ra='10'>{item.enum_checked}</CText>
                                        </CHand>
                                    </CBetween>
                                </CRow>
                                <CRow mx='20' bb='1 #f3f3f3' px='20' h='80' y='center'>
                                    <CText size="28">{item.unit_name}</CText>
                                </CRow>
                                <CRow mx='20' px='20' h='80' y='center'>
                                    <CText size="28">{item.enum_apply_status}</CText>
                                </CRow>
                            </View>

                        )
                    })}

                    {/* 房屋列表 审核通过 */}
                    {this.state.house.map((item,index)=>{
                        return(
                            <View style={{
                                backgroundColor:'#fff', 
                                marginBottom: 10,
                                marginLeft: 10,
                                marginRight: 10,
                                borderRadius: 4
                            }}>
                            <CRow mx='20' bb='1 #f3f3f3' px='20' h='80' y='center'>
                                <CBetween>
                                    <CHand y='center'>
                                        <CText size="28">{item.subdistrict_name}</CText>
                                    </CHand>
                                    <CHand y='center'>
                                        {this.state.default_houseid == item.id ? <CText bg='red' color='#fff' size='24' px='20' py='8' ra='10'>默认</CText>:<CText></CText>}
                                    </CHand>
                                </CBetween>
                            </CRow>
                            <CRow mx='20' bb='1 #f3f3f3' px='20' h='80' y='center'>
                                <CText size="28">{item.unit_name}</CText>
                            </CRow>
                            <CRow mx='20' px='20' h='80' y='center'>
                                <CText size="28">{item.enum_status}</CText>
                            </CRow>
                        </View>

                        )
                    })}






                    {/* 撤回按钮 */}
                    <View style={{margin: 10, height: 10}}>
   
                    </View>

				</CContent>
				
                {/* 头部 */}
				<CHeader bg='#fff' h='96'>
                    <CBetween px='20'>
                        <CHand active={0.6} onPress={(e)=> {
                            this.Nav.goBack()
                        }}>
                            <Icon type='left' size='md' color='#00CC66' />
                        </CHand>

                        <CText size='34'>我的房屋</CText>
                        <TouchableHighlight
                                onPress={ ()=>{ 
                                    // this.Nav.navigate('UserSettingHouseConfirm', {id: this.props.id});
                                 } }
                            >
                            <CText size='26'>添加</CText>
                        </TouchableHighlight>

                    </CBetween>
                </CHeader>
                
			</CPage>
		);
	}
}
